/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.ec.generatepage.web.InfoBroadcastAdvAction
   Module Description   :

   Date Created      : 2010/3/8
   Original Author   : apple.chang
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.ec.generatepage.web;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Properties;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.FastDateFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
import com.yaodian100.core.common.exception.CoreException;
import com.yaodian100.ec.category.entity.Category;
import com.yaodian100.ec.category.service.CategoryService;
import com.yaodian100.ec.common.EcConstant;
import com.yaodian100.ec.generate.entity.GenerateAdvertise;
import com.yaodian100.ec.generate.entity.GenerateContent;
import com.yaodian100.ec.generate.entity.GeneratePosition;
import com.yaodian100.ec.generate.service.GenerateService;

/**
 * 
 * @author apple.chang
 * 
 */
public class InfoBroadcastAdvAction extends ActionSupport implements Preparable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8280417163118221483L;

	private final Logger logger = LoggerFactory.getLogger(InfoBroadcastAdvAction.class);
	private GenerateService generateService;
	private CategoryService categoryService;
	private GenerateAdvertise advertise;
	private GeneratePosition position;
	private List<Category> categoryRoot;
	private GenerateContent content;
	private StringBuilder contents;
	private String advId;
	private String advName;
	private String advType = "IDX_RDADV";
	private String advTarget;
	private String advStatus;
	private String startDate;
	private String endDate;
	private String startTime;
	private String endTime;
	private String mainCateId;
	private String childCateId;

	private String tab1ProdId;
	private String tab1title1;
	private String tab1title2;
	private String tab1title3;
	private String tab1title1Link;
	private String tab1title2Link;
	private String tab1title3Link;

	private String tab2ProdId;
	private String tab2title1;
	private String tab2title2;
	private String tab2title3;
	private String tab2title1Link;
	private String tab2title2Link;
	private String tab2title3Link;

	private String tab3ProdId;
	private String tab3title1;
	private String tab3title2;
	private String tab3title3;
	private String tab3title1Link;
	private String tab3title2Link;
	private String tab3title3Link;

	private String tab1ProdadWord;
	private String tab2ProdadWord;
	private String tab3ProdadWord;
	private String tab1title1adWord;
	private String tab1title2adWord;
	private String tab1title3adWord;
	private String tab2title1adWord;
	private String tab2title2adWord;
	private String tab2title3adWord;
	private String tab3title1adWord;
	private String tab3title2adWord;
	private String tab3title3adWord;

	private String error;
	private final DateFormat PATTERN_DATE_FORMAT = new SimpleDateFormat(EcConstant.PATTERN_TIMESTAMP);

	/**
	 * 新增首页活动快讯/强力放送
	 * 
	 * @return
	 */
	public String addIdxInfoBroadcastAdv() {
		advId = "";
		advType = "IDX_RDADV";
		return "editIdxInfoBroadcastAdv";
	}

	/**
	 * 新增馆首页、分类页活动快讯/强力放送
	 * 
	 * @return
	 */
	public String addInfoBroadcastAdv() {
		advId = "";
		return "editInfoBroadcastAdv";
	}

	private String checkURL(String url) {
		if (!(url.substring(0, 5).equals("https") || url.substring(0, 4).equals("http")
				|| url.substring(0, 3).equals("ftp") || url.substring(0, 4).equals("rtsp") || url.substring(0, 3).equals("mms"))) {
			return "http://" + url;
		}
		return url;
	}

	/**
	 * 编辑首页活动快讯/强力放送
	 * 
	 * @return
	 * @throws Exception
	 */
	public String editIdxInfoBroadcastAdv() throws Exception {
		infoBroadcastAdv();
		return "editIdxInfoBroadcastAdv";
	}

	/**
	 * 编辑馆首页、分类页活动快讯/强力放送
	 * 
	 * @return
	 * @throws Exception
	 */
	public String editInfoBroadcastAdv() throws Exception {
		infoBroadcastAdv();
		return "editInfoBroadcastAdv";
	}

	/**
	 * @return the advId
	 */
	public String getAdvId() {
		return advId;
	}

	/**
	 * @return the advName
	 */
	public String getAdvName() {
		return advName;
	}

	/**
	 * @return the advStatus
	 */
	public String getAdvStatus() {
		return advStatus;
	}

	/**
	 * @return the advTarget
	 */
	public String getAdvTarget() {
		return advTarget;
	}

	/**
	 * @return the advType
	 */
	public String getAdvType() {
		return advType;
	}

	/**
	 * @return the categoryRoot
	 */
	public List<Category> getCategoryRoot() {
		return categoryRoot;
	}

	/**
	 * @return the categoryService
	 */
	public CategoryService getCategoryService() {
		return categoryService;
	}

	/**
	 * @return the childCateId
	 */
	public String getChildCateId() {
		return childCateId;
	}

	/**
	 * @return the content
	 */
	public GenerateContent getContent() {
		return content;
	}

	/**
	 * @return the endDate
	 */
	public String getEndDate() {
		return endDate;
	}

	public String getEndTime() {
		return endTime;
	}

	public String getError() {
		return error;
	}

	/**
	 * @return the mainCateId
	 */
	public String getMainCateId() {
		return mainCateId;
	}

	/**
	 * @return the startDate
	 */
	public String getStartDate() {
		return startDate;
	}

	public String getStartTime() {
		return startTime;
	}

	/**
	 * @return the tab1ProdId
	 */
	public String getTab1ProdId() {
		return tab1ProdId;
	}

	/**
	 * @return the tab1title1
	 */
	public String getTab1title1() {
		return tab1title1;
	}

	/**
	 * @return the tab1title1Link
	 */
	public String getTab1title1Link() {
		return tab1title1Link;
	}

	/**
	 * @return the tab1title2
	 */
	public String getTab1title2() {
		return tab1title2;
	}

	/**
	 * @return the tab1title2Link
	 */
	public String getTab1title2Link() {
		return tab1title2Link;
	}

	/**
	 * @return the tab1title3
	 */
	public String getTab1title3() {
		return tab1title3;
	}

	/**
	 * @return the tab1title3Link
	 */
	public String getTab1title3Link() {
		return tab1title3Link;
	}

	/**
	 * @return the tab2ProdId
	 */
	public String getTab2ProdId() {
		return tab2ProdId;
	}

	/**
	 * @return the tab2title1
	 */
	public String getTab2title1() {
		return tab2title1;
	}

	/**
	 * @return the tab2title1Link
	 */
	public String getTab2title1Link() {
		return tab2title1Link;
	}

	/**
	 * @return the tab2title2
	 */
	public String getTab2title2() {
		return tab2title2;
	}

	/**
	 * @return the tab2title2Link
	 */
	public String getTab2title2Link() {
		return tab2title2Link;
	}

	/**
	 * @return the tab2title3
	 */
	public String getTab2title3() {
		return tab2title3;
	}

	/**
	 * @return the tab2title3Link
	 */
	public String getTab2title3Link() {
		return tab2title3Link;
	}

	/**
	 * @return the tab3ProdId
	 */
	public String getTab3ProdId() {
		return tab3ProdId;
	}

	/**
	 * @return the tab3title1
	 */
	public String getTab3title1() {
		return tab3title1;
	}

	/**
	 * @return the tab3title1Link
	 */
	public String getTab3title1Link() {
		return tab3title1Link;
	}

	/**
	 * @return the tab3title2
	 */
	public String getTab3title2() {
		return tab3title2;
	}

	/**
	 * @return the tab3title2Link
	 */
	public String getTab3title2Link() {
		return tab3title2Link;
	}

	/**
	 * @return the tab3title3
	 */
	public String getTab3title3() {
		return tab3title3;
	}

	/**
	 * @return the tab3title3Link
	 */
	public String getTab3title3Link() {
		return tab3title3Link;
	}

	void infoBroadcastAdv() throws IOException {
		initVariables();
		advertise = generateService.get(Long.parseLong(advId));
		position = generateService.getGeneratePositionByAdvId(Long.parseLong(advId)).get(0);
		content = generateService.getGenerateContentByAdvId(Long.parseLong(advId)).get(0);
		advStatus = advertise.getAdvStatus();
		advType = advertise.getAdvType();
		advName = advertise.getAdvName();
		advTarget = position.getAdvTarget();
		startDate = FastDateFormat.getInstance(EcConstant.PATTERN_DATE).format(advertise.getStartDate());
		endDate = FastDateFormat.getInstance(EcConstant.PATTERN_DATE).format(advertise.getEndDate());
		if (StringUtils.equalsIgnoreCase("000_RDADV", advertise.getAdvType())) {
			mainCateId = position.getMainCateId().toString();
		} else if (StringUtils.equalsIgnoreCase("100_RDADV", advertise.getAdvType())) {
			mainCateId = position.getMainCateId().toString();
			childCateId = position.getChildCateId().toString();
		}
		readPropertise(content);
	}

	private boolean infoBroadcastAdvValidate() throws CoreException, ParseException, IOException {
		/**************************** 必填栏位 ****************************/
		logger.info("advName = " + advName);

		if (StringUtils.isBlank(advName)) {
			addFieldError("advName", "请输入广告名称");
		}

		if (StringUtils.isBlank(startDate)) {
			addFieldError("startDate", "请输入起始日期");
		}

		if (StringUtils.isBlank(endDate)) {
			addFieldError("endDate", "请输入结束日期");
		}

		if (StringUtils.equalsIgnoreCase("000_RDADV", advType)) {
			if (StringUtils.isBlank(mainCateId)) {
				addFieldError("mainCateId", "请选择馆别");
			}
		} else if (StringUtils.equalsIgnoreCase("100_RDADV", advType)) {
			if (StringUtils.isBlank(mainCateId)) {
				addFieldError("mainCateId", "请选择馆别");
			}
			if (StringUtils.isBlank(childCateId)) {
				addFieldError("childCateId", "请选次分类");
			}
		}

		// 1
		if (StringUtils.isBlank(tab1ProdId)) {
			addFieldError("tab1ProdId", "请输入Tab1 商品编号");
		} else if (!generateService.isProductExist(tab1ProdId)) {
			error = "1";
		}

		if (StringUtils.isBlank(tab1title1)) {
			addFieldError("tab1title1", "请输入Tab1 标题一");
		}

		if (StringUtils.isBlank(tab1title1Link)) {
			addFieldError("tab1title1Link", "请输入Tab1 标题一点击连结");
		}

		if (StringUtils.isBlank(tab1title2)) {
			addFieldError("tab1title2", "请输入Tab1 标题二");
		}

		if (StringUtils.isBlank(tab1title2Link)) {
			addFieldError("tab1title2Link", "请输入Tab1 标题二点击连结");
		}

		if (StringUtils.isBlank(tab1title3)) {
			addFieldError("tab1title3", "请输入Tab1 标题三");
		}

		if (StringUtils.isBlank(tab1title3Link)) {
			addFieldError("tab1title3Link", "请输入Tab1 标题三点击连结");
		}

		// 2
		if (StringUtils.isBlank(tab2ProdId)) {
			addFieldError("tab2ProdId", "请输入Tab2 商品编号");
		} else if (!generateService.isProductExist(tab2ProdId)) {
			error = (StringUtils.isNotBlank(error) ? error + ",2" : "2");
		}

		if (StringUtils.isBlank(tab2title1)) {
			addFieldError("tab2title1", "请输入Tab2 标题一");
		}

		if (StringUtils.isBlank(tab2title1Link)) {
			addFieldError("tab2title1Link", "请输入Tab2 标题一点击连结");
		}

		if (StringUtils.isBlank(tab2title2)) {
			addFieldError("tab2title2", "请输入Tab2 标题二");
		}

		if (StringUtils.isBlank(tab2title2Link)) {
			addFieldError("tab2title2Link", "请输入Tab2 标题二点击连结");
		}

		if (StringUtils.isBlank(tab2title3)) {
			addFieldError("tab2title3", "请输入Tab2 标题三");
		}

		if (StringUtils.isBlank(tab2title3Link)) {
			addFieldError("tab2title3Link", "请输入Tab2 标题三点击连结");
		}

		// 3
		if (StringUtils.isBlank(tab3ProdId)) {
			addFieldError("tab3ProdId", "请输入Tab3 商品编号");
		} else if (!generateService.isProductExist(tab3ProdId)) {
			error = (StringUtils.isNotBlank(error) ? error + ",3" : "3");
		}

		if (StringUtils.isBlank(tab3title1)) {
			addFieldError("tab3title1", "请输入Tab3 标题一");
		}

		if (StringUtils.isBlank(tab3title1Link)) {
			addFieldError("tab3title1Link", "请输入Tab3 标题一点击连结");
		}

		if (StringUtils.isBlank(tab3title2)) {
			addFieldError("tab3title2", "请输入Tab3 标题二");
		}

		if (StringUtils.isBlank(tab3title2Link)) {
			addFieldError("tab3title2Link", "请输入Tab3 标题二点击连结");
		}

		if (StringUtils.isBlank(tab3title3)) {
			addFieldError("tab3title3", "请输入Tab3 标题三");
		}

		if (StringUtils.isBlank(tab3title3Link)) {
			addFieldError("tab3title3Link", "请输入Tab3 标题三点击连结");
		}

		if (getFieldErrors().isEmpty() && StringUtils.isBlank(error)) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * 初始化变数值
	 */
	void initVariables() {
		advertise = new GenerateAdvertise();
		position = new GeneratePosition();
		content = new GenerateContent();

		advStatus = "";
		advName = "";
		startDate = "";
		endDate = "";
		mainCateId = "";
		childCateId = "";
		advType = "";
		advTarget = "";

		tab1ProdId = "";
		tab1title1 = "";
		tab1title2 = "";
		tab1title3 = "";
		tab1title1Link = "";
		tab1title2Link = "";
		tab1title3Link = "";

		tab2ProdId = "";
		tab2title1 = "";
		tab2title2 = "";
		tab2title3 = "";
		tab2title1Link = "";
		tab2title2Link = "";
		tab2title3Link = "";

		tab3ProdId = "";
		tab3title1 = "";
		tab3title2 = "";
		tab3title3 = "";
		tab3title1Link = "";
		tab3title2Link = "";
		tab3title3Link = "";
	}

	public void prepare() throws Exception {
		clearErrorsAndMessages();
		if (null == categoryRoot) {
			categoryRoot = categoryService.getChild(0l);
		}
	}

	/**
	 * 從db讀取propertise資料
	 * 
	 * @param content
	 * @throws IOException
	 */
	void readPropertise(GenerateContent content) throws IOException {
		Properties prop = new Properties();
		Reader reader = new StringReader(content.getContents());
		prop.load(reader);
		reader.close();

		tab1ProdId = StringUtils.defaultString(prop.get("tab1ProdId").toString());
		tab1title1 = StringUtils.defaultString(prop.get("tab1title1").toString());
		tab1title2 = StringUtils.defaultString(prop.get("tab1title2").toString());
		tab1title3 = StringUtils.defaultString(prop.get("tab1title3").toString());
		tab1title1Link = StringUtils.defaultString(prop.get("tab1title1Link").toString());
		tab1title2Link = StringUtils.defaultString(prop.get("tab1title2Link").toString());
		tab1title3Link = StringUtils.defaultString(prop.get("tab1title3Link").toString());

		tab2ProdId = StringUtils.defaultString(prop.get("tab2ProdId").toString());
		tab2title1 = StringUtils.defaultString(prop.get("tab2title1").toString());
		tab2title2 = StringUtils.defaultString(prop.get("tab2title2").toString());
		tab2title3 = StringUtils.defaultString(prop.get("tab2title3").toString());
		tab2title1Link = StringUtils.defaultString(prop.get("tab2title1Link").toString());
		tab2title2Link = StringUtils.defaultString(prop.get("tab2title2Link").toString());
		tab2title3Link = StringUtils.defaultString(prop.get("tab2title3Link").toString());

		tab3ProdId = StringUtils.defaultString(prop.get("tab3ProdId").toString());
		tab3title1 = StringUtils.defaultString(prop.get("tab3title1").toString());
		tab3title2 = StringUtils.defaultString(prop.get("tab3title2").toString());
		tab3title3 = StringUtils.defaultString(prop.get("tab3title3").toString());
		tab3title1Link = StringUtils.defaultString(prop.get("tab3title1Link").toString());
		tab3title2Link = StringUtils.defaultString(prop.get("tab3title2Link").toString());
		tab3title3Link = StringUtils.defaultString(prop.get("tab3title3Link").toString());

		if (prop.containsKey("tab1ProdadWord")) {
			tab1ProdadWord = StringUtils.defaultString(prop.get("tab1ProdadWord").toString(), "");
		}
		if (prop.containsKey("tab2ProdadWord")) {
			tab2ProdadWord = StringUtils.defaultString(prop.get("tab2ProdadWord").toString(), "");
		}
		if (prop.containsKey("tab3ProdadWord")) {
			tab3ProdadWord = StringUtils.defaultString(prop.get("tab3ProdadWord").toString(), "");
		}
		if (prop.containsKey("tab1title1adWord")) {
			tab1title1adWord = StringUtils.defaultString(prop.get("tab1title1adWord").toString(), "");
		}
		if (prop.containsKey("tab1title2adWord")) {
			tab1title2adWord = StringUtils.defaultString(prop.get("tab1title2adWord").toString(), "");
		}
		if (prop.containsKey("tab1title3adWord")) {
			tab1title3adWord = StringUtils.defaultString(prop.get("tab1title3adWord").toString(), "");
		}

		if (prop.containsKey("tab2title1adWord")) {
			tab2title1adWord = StringUtils.defaultString(prop.get("tab2title1adWord").toString(), "");
		}
		if (prop.containsKey("tab2title2adWord")) {
			tab2title2adWord = StringUtils.defaultString(prop.get("tab2title2adWord").toString(), "");
		}
		if (prop.containsKey("tab2title3adWord")) {
			tab2title3adWord = StringUtils.defaultString(prop.get("tab2title3adWord").toString(), "");
		}

		if (prop.containsKey("tab3title1adWord")) {
			tab3title1adWord = StringUtils.defaultString(prop.get("tab3title1adWord").toString(), "");
		}
		if (prop.containsKey("tab3title2adWord")) {
			tab3title2adWord = StringUtils.defaultString(prop.get("tab3title2adWord").toString(), "");
		}
		if (prop.containsKey("tab3title3adWord")) {
			tab3title3adWord = StringUtils.defaultString(prop.get("tab3title3adWord").toString(), "");
		}
	}

	/**
	 * 储存广告
	 * 
	 * @return
	 * @throws Exception
	 * @throws IOException
	 * @throws ParseException
	 * @throws CoreException
	 * @throws NumberFormatException
	 */
	public String saveInfoBroadcastAdv() throws NumberFormatException, CoreException, ParseException, IOException,
			Exception {
		boolean result = false;
		if (infoBroadcastAdvValidate()) {
			contents = new StringBuilder("");

			contents.append("tab1ProdId=").append(tab1ProdId).append("\n");
			contents.append("tab1title1=").append(tab1title1).append("\n");
			contents.append("tab1title2=").append(tab1title2).append("\n");
			contents.append("tab1title3=").append(tab1title3).append("\n");
			contents.append("tab1title1Link=").append(checkURL(tab1title1Link)).append("\n");
			contents.append("tab1title2Link=").append(checkURL(tab1title2Link)).append("\n");
			contents.append("tab1title3Link=").append(checkURL(tab1title3Link)).append("\n");

			contents.append("tab2ProdId=").append(tab2ProdId).append("\n");
			contents.append("tab2title1=").append(tab2title1).append("\n");
			contents.append("tab2title2=").append(tab2title2).append("\n");
			contents.append("tab2title3=").append(tab2title3).append("\n");
			contents.append("tab2title1Link=").append(checkURL(tab2title1Link)).append("\n");
			contents.append("tab2title2Link=").append(checkURL(tab2title2Link)).append("\n");
			contents.append("tab2title3Link=").append(checkURL(tab2title3Link)).append("\n");

			contents.append("tab3ProdId=").append(tab3ProdId).append("\n");
			contents.append("tab3title1=").append(tab3title1).append("\n");
			contents.append("tab3title2=").append(tab3title2).append("\n");
			contents.append("tab3title3=").append(tab3title3).append("\n");
			contents.append("tab3title1Link=").append(checkURL(tab3title1Link)).append("\n");
			contents.append("tab3title2Link=").append(checkURL(tab3title2Link)).append("\n");
			contents.append("tab3title3Link=").append(checkURL(tab3title3Link)).append("\n");

			contents.append("tab1ProdadWord=").append(StringUtils.defaultString(tab1ProdadWord)).append("\n");
			contents.append("tab2ProdadWord=").append(StringUtils.defaultString(tab2ProdadWord)).append("\n");
			contents.append("tab3ProdadWord=").append(StringUtils.defaultString(tab3ProdadWord)).append("\n");
			contents.append("tab1title1adWord=").append(StringUtils.defaultString(tab1title1adWord)).append("\n");
			contents.append("tab1title2adWord=").append(StringUtils.defaultString(tab1title2adWord)).append("\n");
			contents.append("tab1title3adWord=").append(StringUtils.defaultString(tab1title3adWord)).append("\n");
			contents.append("tab2title1adWord=").append(StringUtils.defaultString(tab2title1adWord)).append("\n");
			contents.append("tab2title2adWord=").append(StringUtils.defaultString(tab2title2adWord)).append("\n");
			contents.append("tab2title3adWord=").append(StringUtils.defaultString(tab2title3adWord)).append("\n");
			contents.append("tab3title1adWord=").append(StringUtils.defaultString(tab3title1adWord)).append("\n");
			contents.append("tab3title2adWord=").append(StringUtils.defaultString(tab3title2adWord)).append("\n");
			contents.append("tab3title3adWord=").append(StringUtils.defaultString(tab3title3adWord)).append("\n");

			if (StringUtils.isBlank(advId)) {
				advertise = new GenerateAdvertise();
				position = new GeneratePosition();
				content = new GenerateContent();
			} else {
				advertise = generateService.get(Long.parseLong(advId));
				position = generateService.getGeneratePositionByAdvId(Long.parseLong(advId)).get(0);
				content = generateService.getGenerateContentByAdvId(Long.parseLong(advId)).get(0);
			}
			// set advertise
			advertise.setAdvType(advType);
			advertise.setAdvName(advName.trim());
			if (StringUtils.equalsIgnoreCase("IDX_RDADV", advType)) {
				advertise.setStartDate(PATTERN_DATE_FORMAT.parse(startDate + " " + startTime + ":00"));
				advertise.setEndDate(PATTERN_DATE_FORMAT.parse(endDate + " " + endTime + ":59"));
			} else {
				advertise.setStartDate(PATTERN_DATE_FORMAT.parse(startDate + " 00:00:00"));
				advertise.setEndDate(PATTERN_DATE_FORMAT.parse(endDate + " 23:59:59"));
			}
			advertise.setAdvStatus(advStatus);
			position.setAdvTarget(advTarget);
			if (StringUtils.equalsIgnoreCase("000_RDADV", advType)) {
				position.setMainCateId(Long.parseLong(mainCateId));
			}
			if (StringUtils.equalsIgnoreCase("100_RDADV", advType)) {
				position.setMainCateId(Long.parseLong(mainCateId));
				position.setChildCateId(Long.parseLong(childCateId));
			}
			content.setContents(contents.toString());

			if (StringUtils.isBlank(advId)) {
				result = generateService.saveGenerateCombine(advertise, position, content);
			} else {
				result = generateService.updateGenerateCombine(advertise, position, content);
			}
			contents.setLength(0);
			// 存檔後立刻執行產生檔案的邏輯
			generateService.generateRightDownAdvV2(Long.valueOf(0));
			if (!result) {
				if (StringUtils.equalsIgnoreCase("IDX_RDADV", advType)) {
					return "editIdxInfoBroadcastAdv";
				} else {
					return "editInfoBroadcastAdv";
				}
			} else {
				if (StringUtils.equalsIgnoreCase("IDX_RDADV", advType)) {
					advId = advertise.getId().toString();
					addActionMessage("储存成功");
					return editIdxInfoBroadcastAdv();
				} else {
					return "listAdv";
				}
			}

		}
		if (StringUtils.equalsIgnoreCase("IDX_RDADV", advType)) {
			return "editIdxInfoBroadcastAdv";
		} else {
			return "editInfoBroadcastAdv";
		}
	}

	/**
	 * @param advId the advId to set
	 */
	public void setAdvId(String advId) {
		this.advId = advId;
	}

	/**
	 * @param advName the advName to set
	 */
	public void setAdvName(String advName) {
		this.advName = advName;
	}

	/**
	 * @param advStatus the advStatus to set
	 */
	public void setAdvStatus(String advStatus) {
		this.advStatus = advStatus;
	}

	/**
	 * @param advTarget the advTarget to set
	 */
	public void setAdvTarget(String advTarget) {
		this.advTarget = advTarget;
	}

	/**
	 * @param advType the advType to set
	 */
	public void setAdvType(String advType) {
		this.advType = advType;
	}

	/**
	 * @param categoryRoot the categoryRoot to set
	 */
	public void setCategoryRoot(List<Category> categoryRoot) {
		this.categoryRoot = categoryRoot;
	}

	/**
	 * @param categoryService the categoryService to set
	 */
	public void setCategoryService(CategoryService categoryService) {
		this.categoryService = categoryService;
	}

	/**
	 * @param childCateId the childCateId to set
	 */
	public void setChildCateId(String childCateId) {
		this.childCateId = childCateId;
	}

	/**
	 * @param content the content to set
	 */
	public void setContent(GenerateContent content) {
		this.content = content;
	}

	/**
	 * @param endDate the endDate to set
	 */
	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public void setError(String error) {
		this.error = error;
	}

	/**
	 * @param generateService the generateService to set
	 */
	public void setGenerateService(GenerateService generateService) {
		this.generateService = generateService;
	}

	/**
	 * @param mainCateId the mainCateId to set
	 */
	public void setMainCateId(String mainCateId) {
		this.mainCateId = mainCateId;
	}

	/**
	 * @param startDate the startDate to set
	 */
	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	/**
	 * @param tab1ProdId the tab1ProdId to set
	 */
	public void setTab1ProdId(String tab1ProdId) {
		this.tab1ProdId = tab1ProdId;
	}

	/**
	 * @param tab1title1 the tab1title1 to set
	 */
	public void setTab1title1(String tab1title1) {
		this.tab1title1 = tab1title1;
	}

	/**
	 * @param tab1title1Link the tab1title1Link to set
	 */
	public void setTab1title1Link(String tab1title1Link) {
		this.tab1title1Link = tab1title1Link;
	}

	/**
	 * @param tab1title2 the tab1title2 to set
	 */
	public void setTab1title2(String tab1title2) {
		this.tab1title2 = tab1title2;
	}

	/**
	 * @param tab1title2Link the tab1title2Link to set
	 */
	public void setTab1title2Link(String tab1title2Link) {
		this.tab1title2Link = tab1title2Link;
	}

	/**
	 * @param tab1title3 the tab1title3 to set
	 */
	public void setTab1title3(String tab1title3) {
		this.tab1title3 = tab1title3;
	}

	/**
	 * @param tab1title3Link the tab1title3Link to set
	 */
	public void setTab1title3Link(String tab1title3Link) {
		this.tab1title3Link = tab1title3Link;
	}

	/**
	 * @param tab2ProdId the tab2ProdId to set
	 */
	public void setTab2ProdId(String tab2ProdId) {
		this.tab2ProdId = tab2ProdId;
	}

	/**
	 * @param tab2title1 the tab2title1 to set
	 */
	public void setTab2title1(String tab2title1) {
		this.tab2title1 = tab2title1;
	}

	/**
	 * @param tab2title1Link the tab2title1Link to set
	 */
	public void setTab2title1Link(String tab2title1Link) {
		this.tab2title1Link = tab2title1Link;
	}

	/**
	 * @param tab2title2 the tab2title2 to set
	 */
	public void setTab2title2(String tab2title2) {
		this.tab2title2 = tab2title2;
	}

	/**
	 * @param tab2title2Link the tab2title2Link to set
	 */
	public void setTab2title2Link(String tab2title2Link) {
		this.tab2title2Link = tab2title2Link;
	}

	/**
	 * @param tab2title3 the tab2title3 to set
	 */
	public void setTab2title3(String tab2title3) {
		this.tab2title3 = tab2title3;
	}

	/**
	 * @param tab2title3Link the tab2title3Link to set
	 */
	public void setTab2title3Link(String tab2title3Link) {
		this.tab2title3Link = tab2title3Link;
	}

	/**
	 * @param tab3ProdId the tab3ProdId to set
	 */
	public void setTab3ProdId(String tab3ProdId) {
		this.tab3ProdId = tab3ProdId;
	}

	/**
	 * @param tab3title1 the tab3title1 to set
	 */
	public void setTab3title1(String tab3title1) {
		this.tab3title1 = tab3title1;
	}

	/**
	 * @param tab3title1Link the tab3title1Link to set
	 */
	public void setTab3title1Link(String tab3title1Link) {
		this.tab3title1Link = tab3title1Link;
	}

	/**
	 * @param tab3title2 the tab3title2 to set
	 */
	public void setTab3title2(String tab3title2) {
		this.tab3title2 = tab3title2;
	}

	/**
	 * @param tab3title2Link the tab3title2Link to set
	 */
	public void setTab3title2Link(String tab3title2Link) {
		this.tab3title2Link = tab3title2Link;
	}

	/**
	 * @param tab3title3 the tab3title3 to set
	 */
	public void setTab3title3(String tab3title3) {
		this.tab3title3 = tab3title3;
	}

	/**
	 * @param tab3title3Link the tab3title3Link to set
	 */
	public void setTab3title3Link(String tab3title3Link) {
		this.tab3title3Link = tab3title3Link;
	}

	public String getTab1ProdadWord() {
		return tab1ProdadWord;
	}

	public void setTab1ProdadWord(String tab1ProdadWord) {
		this.tab1ProdadWord = tab1ProdadWord;
	}

	public String getTab2ProdadWord() {
		return tab2ProdadWord;
	}

	public void setTab2ProdadWord(String tab2ProdadWord) {
		this.tab2ProdadWord = tab2ProdadWord;
	}

	public String getTab3ProdadWord() {
		return tab3ProdadWord;
	}

	public void setTab3ProdadWord(String tab3ProdadWord) {
		this.tab3ProdadWord = tab3ProdadWord;
	}

	public String getTab1title1adWord() {
		return tab1title1adWord;
	}

	public void setTab1title1adWord(String tab1title1adWord) {
		this.tab1title1adWord = tab1title1adWord;
	}

	public String getTab1title2adWord() {
		return tab1title2adWord;
	}

	public void setTab1title2adWord(String tab1title2adWord) {
		this.tab1title2adWord = tab1title2adWord;
	}

	public String getTab1title3adWord() {
		return tab1title3adWord;
	}

	public void setTab1title3adWord(String tab1title3adWord) {
		this.tab1title3adWord = tab1title3adWord;
	}

	public String getTab2title1adWord() {
		return tab2title1adWord;
	}

	public void setTab2title1adWord(String tab2title1adWord) {
		this.tab2title1adWord = tab2title1adWord;
	}

	public String getTab2title2adWord() {
		return tab2title2adWord;
	}

	public void setTab2title2adWord(String tab2title2adWord) {
		this.tab2title2adWord = tab2title2adWord;
	}

	public String getTab2title3adWord() {
		return tab2title3adWord;
	}

	public void setTab2title3adWord(String tab2title3adWord) {
		this.tab2title3adWord = tab2title3adWord;
	}

	public String getTab3title1adWord() {
		return tab3title1adWord;
	}

	public void setTab3title1adWord(String tab3title1adWord) {
		this.tab3title1adWord = tab3title1adWord;
	}

	public String getTab3title2adWord() {
		return tab3title2adWord;
	}

	public void setTab3title2adWord(String tab3title2adWord) {
		this.tab3title2adWord = tab3title2adWord;
	}

	public String getTab3title3adWord() {
		return tab3title3adWord;
	}

	public void setTab3title3adWord(String tab3title3adWord) {
		this.tab3title3adWord = tab3title3adWord;
	}
}
